package com.shaoyu.tools.testcase.pressuretest;

import com.shaoyu.spring.study.validate.annotation.ValidateInterceptMethod;
import com.shaoyu.spring.study.validate.core.ValidateContext;
import com.shaoyu.tools.testcase.pressuretest.intercept.Interceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Desc :
 * @Author: shaoyu
 * @Date : 2022/8/25 14:47
 */
@Component
public class InterceptPressureTest {

    @Autowired
    Interceptor interceptor;

    public String noIntercept(String param) throws InterruptedException {
        interceptor.validateString(param);
        Thread.sleep(1);
        return null;
    }

    @ValidateInterceptMethod("test")
    public String hasIntercept(String param)throws InterruptedException {
        Thread.sleep(1);
        return null;
    }

    @ValidateInterceptMethod("testContext")
    public String testContext(Integer i){
        System.out.println(Thread.currentThread().getName()+":"+ ValidateContext.getCurrentContext().get("test"));
        return i.toString();
    }
}
